package com.trainsmart.example.mdi.control
{
	import com.trainsmart.smartmvc.Context;
	import com.trainsmart.smartmvc.CtrlBase;
	
	import mx.collections.ArrayCollection;
	import mx.controls.List;

	public class UnRegisterWinCtrl extends CtrlBase
	{
		public function UnRegisterWinCtrl(context:Context)
		{
			super(context);
		}
		override public function execute(request:Object=null, response:Function=null):void
		{
			var list:List = context.getInSession("list") as List;
			var array:ArrayCollection = list.dataProvider as ArrayCollection;
			var newarray:Array = new Array();
			
			var winId:Object = request["winId"];
			for(var i:int = 0; i<array.length;i++){
				if(array.getItemAt(i)!=winId)
					newarray.push(array[i]);
			}
			list.dataProvider = newarray;
		}
		
	}
}